package com.kws.system.controller.contractManagement;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kws.common.core.domain.R;
import com.kws.common.log.annotation.Log;
import com.kws.common.log.enums.BusinessType;
import com.kws.system.domain.contractManagementDao.info.QueryContractManagementInfo;
import com.kws.system.service.contractTemplateService.ContractManagementService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <b>ContractManagementController</b>
 *
 * @description: ContractManagementController <br>
 * @date: 2024/11/18 14:57 <br>
 * @author: lhm <br>
 * @version: 1.0 <br>
 */

@Api(tags = "合同管理模块")
@RestController
public class ContractManagementController {
    private static final Logger logger = LoggerFactory.getLogger(ContractManagementController.class);

    @Autowired
    private ContractManagementService contractManagementService;

    @ApiOperation("后台分页查询合同管理列表")
    @GetMapping("/query/contractManagement/page")
    public R<Page<QueryContractManagementInfo>> queryContractManagementPage(@RequestParam(value = "pageNum",defaultValue = "1") Integer pageNum,
                                                                            @RequestParam(value = "pageSize",defaultValue = "10") Integer pageSize,
                                                                            @RequestParam(required = false) String contractName,
                                                                            @RequestParam(required = false) Integer type,
                                                                            @RequestParam(required = false) String startDate,
                                                                            @RequestParam(required = false) String endDate){
        R<Page<QueryContractManagementInfo>> result = contractManagementService.queryContractManagementPage(pageNum,pageSize,contractName,type,startDate,endDate);
        return result;
    }

    @ApiOperation("根据ID查询合同详情")
    @GetMapping("/query/contractManagement/byId")
    public R<QueryContractManagementInfo> queryContractManagementById(@RequestParam Long id){
        QueryContractManagementInfo info = contractManagementService.queryContractManagementById(id);
        return R.ok(info);
    }

    @ApiOperation("根据ID删除合同")
    @Log(title = "删除合同", businessType = BusinessType.DELETE)
    @GetMapping("/delete/contractManagement/byId")
    public R deleteContractManagementById(@RequestParam Long id){
        boolean status = contractManagementService.deleteContractManagementById(id);
        return R.ok(status);
    }
}
